import "./css/index.css";
import "./less/index.less";
import imgObj from "@/assets/logo.png";
import axios from "axios";
import { checkUserName, checkPassWord } from "Utils/check.js";

// const unameResult = checkUserName('itheima007')
// const pwdResult = checkPassWord('7654321')
// console.log(checkUserName, checkPassWord )
document.querySelector(".login-btn").addEventListener("click", () => {
  const username = document.querySelector(".username").value;
  const password = document.querySelector(".password").value;

  if (!checkUserName(username)) {
    alert("用户名长度要大于等于8位");
    return;
  } else if (!checkPassWord(password)) {
    alert("密码长度要求大于等于6位");
    return;
  }

  console.log("用户名和密码长度符合要求");

  axios({
    url: "http://hmajax.itheima.net/api/register",
    method: "POST",
    data: {
      username,
      password,
    },
  })
    .then((result) => {
      alert(result.data.message);
    })
    .catch((error) => {
      alert(error.response.data.message);
    });
});
document.querySelector("img").src = imgObj;

const arr = [1, 2, 3];
const result = arr.map((val) => val + 1);
console.log(result);

